!/bin/bash
DT=`date -d '-1 day' +%Y-%m-%d`

#sqoop import customer
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,date_format(update_date_time,'%Y-%m-%d') as dt from customer where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer \
-m 1


#sqoop import customer_appeal
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,date_format(create_date_time,'%Y-%m-%d') as dt from customer_appeal where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer_appeal \
-m 1


#sqoop import customer_clue
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,date_format(update_date_time,'%Y-%m-%d') as dt from customer_clue where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer_clue \
-m 1


#sqoop import customer_relationship
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,date_format(update_date_time,'%Y-%m-%d') as dt from customer_relationship where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer_relationship \
-m 1


#sqoop import employee
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *  from employee where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table employee \
-m 1

#sqoop import itcast_clazz
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_clazz where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table itcast_clazz \
-m 1

#sqoop import itcast_school
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_school where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table itcast_school \
-m 1

#sqoop import itcast_subject
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_subject where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table itcast_subject \
-m 1

#sqoop import scrm_department
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from scrm_department where 1=1 and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table scrm_department \
-m 1

####################### 每日增量及更新采集 #######################

#sqoop import customer 每日增量及更新采集
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${DT}' as dt from customer where 1=1 and (create_date_time between '${DT} 00:00:00' and '${DT} 23:59:59') or (update_date_time between '${DT} 00:00:00' and '${DT} 23:59:59') and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer \
-m 1

#sqoop import customer_appeal 每日增量及更新采集
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${DT}' as dt from customer_appeal where 1=1 and (create_date_time between '${DT} 00:00:00' and '${DT} 23:59:59') or (update_date_time between '${DT} 00:00:00' and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer_appeal \
-m 1

#sqoop import customer_clue 每日增量及更新采集
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${DT}' as dt from customer_clue where 1=1 and (create_date_time between '${DT} 00:00:00' and '${DT} 23:59:59') or (update_date_time between '${DT} 00:00:00' and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer_clue \
-m 1

#sqoop import customer_relationship 每日增量及更新采集
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${DT}' as dt from customer_relationship where 1=1 and (create_date_time between '${DT} 00:00:00' and '${DT} 23:59:59') or (update_date_time between '${DT} 00:00:00' and  \$CONDITIONS" \
--hcatalog-database edu_online_ods \
--hcatalog-table customer_relationship \
-m 1